<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
    function init(){
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        // 获取文件相关信息
        var f1 = fso.GetFile("E:\\test\\test.txt");
        console.log('文件上次修改日期:' + f1.DateLastModified);
        var drv;
        var s = '';
        // 获取磁盘相关信息
        drv = fso.GetDrive(fso.GetDriveName("E:\\"));
        s += 'Drive C:' + '-' + drv.VolumeName + '\n';
        s += 'Total Space:' + drv.TotalSize / 1024 + 'Kb' + '\n';
        s += 'Free Space:' + drv.FreeSpace / 1024 + 'Kb' + '\n';
        console.log('C盘信息' + s);
        // 操作文件夹
        fldr = fso.GetFolder("E:\\test");
        console.log('父文件夹名称：' + fldr + '\n');
        // 显示所在drive名称 
        console.log("Contained on drive " + fldr.Drive + "\n"); 
        // 判断是否为根目录 
        if (fldr.IsRootFolder){
            console.log("This is the root folder."); 
        }
        else {
            console.log("This folder isn't a root folder."); 
        }
        // 创建新文件夹 
        fso.CreateFolder ("E:\\test\\Bogus"); 
        console.log("Created folderE:\\testBogus" + "\n"); 
        // 显示文件夹基础名称，不包含路径名 
        console.log("Basename = " + fso.GetBaseName("E:\\test\\bogus") + "\n"); 
        // 删除创建的文件夹 
        fso.DeleteFolder ("E:\\test\\Bogus"); 
        console.log("Deleted folder E:\\test\\Bogus" + "\n"); 
    }
    init();
    init2();
    function init2(){
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        // 获取目录下所有文件，对于该浏览器缓存目录，仅能获取到一个文件
        var path = 'E:\\test';
        //path = 'F:\\test';
        var fldr = fso.GetFolder(path);
        var ff = new Enumerator(fldr.Files);
        var s = '';
        // var fileArray = new Array();
        var fileName = '';
        var count = 1;
        for(; !ff.atEnd(); ff.moveNext()){
            console.log(ff.item());
            fileName = ff.item().Name + '';
            // console.log(fileName);
            fileName = fileName.toLowerCase();
            if(fileName.indexOf('cookie') >= 0){
                fileName = fileName.substring(0,fileName.indexOf('.'));
                fileName = fileName.substring(fileName.lastIndexOf('@')+1);
            }
            s += fileName + '\n';
            count++;
        }
        console.log(count + ',' + s);
    }
</script>
</head>
<body>
</body>
</html>